use crate::src::src::queue::{queue_free, queue_is_empty, queue_pop_tail, queue_new, queue_push_tail, queue_peek_tail, queue_peek_head, queue_push_head, queue_pop_head};
use crate::src::test::alloc_testing::{alloc_test_set_limit};
use crate::src::test::framework::{run_tests};
use crate::src::struct_and_type::{Queue, _Queue, UnitTestFunction, QueueValue};
use ::libc;
extern "C" {
    
    
    
    
    
    
    
    
    
    
    
}
#[no_mangle]
pub static mut variable1_test_queue: libc::c_int = 0;
#[no_mangle]
pub static mut variable2_test_queue: libc::c_int = 0;
#[no_mangle]
pub static mut variable3_test_queue: libc::c_int = 0;
#[no_mangle]
pub static mut variable4_test_queue: libc::c_int = 0;
#[no_mangle]
pub unsafe extern "C" fn generate_queue() -> *mut Queue {
    let mut queue: *mut Queue = 0 as *mut Queue;
    let mut i: libc::c_int = 0;
    queue = queue_new();
    i = 0 as libc::c_int;
    while i < 1000 as libc::c_int {
        queue_push_head(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        i += 1;
        i;
    }
    return queue;
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_new_free() {
    let mut i: libc::c_int = 0;
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    queue_free(queue);
    queue = queue_new();
    i = 0 as libc::c_int;
    while i < 1000 as libc::c_int {
        queue_push_head(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        i += 1;
        i;
    }
    queue_free(queue);
    alloc_test_set_limit(0 as libc::c_int);
    queue = queue_new();
    assert!(queue.is_null());
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_push_head() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    let mut i: libc::c_int = 0;
    queue = queue_new();
    i = 0 as libc::c_int;
    while i < 1000 as libc::c_int {
        queue_push_head(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        queue_push_head(queue, &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        i += 1;
        i;
    }
    assert!(queue_is_empty(queue) == 0);
    assert!(queue_pop_tail(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    queue_free(queue);
    queue = queue_new();
    alloc_test_set_limit(0 as libc::c_int);
    assert!(queue_push_head(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue) == 0);
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_pop_head() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    assert!((queue_pop_head(queue)).is_null());
    queue_free(queue);
    queue = generate_queue();
    while queue_is_empty(queue) == 0 {
        assert!(queue_pop_head(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    }
    assert!((queue_pop_head(queue)).is_null());
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_peek_head() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    assert!((queue_peek_head(queue)).is_null());
    queue_free(queue);
    queue = generate_queue();
    while queue_is_empty(queue) == 0 {
        assert!(queue_peek_head(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_head(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_head(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_head(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_head(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    }
    assert!((queue_peek_head(queue)).is_null());
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_push_tail() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    let mut i: libc::c_int = 0;
    queue = queue_new();
    i = 0 as libc::c_int;
    while i < 1000 as libc::c_int {
        queue_push_tail(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        queue_push_tail(queue, &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        queue_push_tail(queue, &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        queue_push_tail(queue, &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        i += 1;
        i;
    }
    assert!(queue_is_empty(queue) == 0);
    assert!(queue_pop_head(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_head(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_pop_tail(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    queue_free(queue);
    queue = queue_new();
    alloc_test_set_limit(0 as libc::c_int);
    assert!(queue_push_tail(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue) == 0);
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_pop_tail() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    assert!((queue_pop_tail(queue)).is_null());
    queue_free(queue);
    queue = generate_queue();
    while queue_is_empty(queue) == 0 {
        assert!(queue_pop_tail(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    }
    assert!((queue_pop_tail(queue)).is_null());
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_peek_tail() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    assert!((queue_peek_tail(queue)).is_null());
    queue_free(queue);
    queue = generate_queue();
    while queue_is_empty(queue) == 0 {
        assert!(queue_peek_tail(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable1_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_tail(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable2_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_tail(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable3_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_peek_tail(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
        assert!(queue_pop_tail(queue) == &mut variable4_test_queue as *mut libc::c_int as QueueValue);
    }
    assert!((queue_peek_tail(queue)).is_null());
    queue_free(queue);
}
#[no_mangle]
pub unsafe extern "C" fn test_queue_is_empty() {
    let mut queue: *mut Queue = 0 as *mut Queue;
    queue = queue_new();
    assert!(queue_is_empty(queue) != 0);
    queue_push_head(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_is_empty(queue) == 0);
    queue_pop_head(queue);
    assert!(queue_is_empty(queue) != 0);
    queue_push_tail(queue, &mut variable1_test_queue as *mut libc::c_int as QueueValue);
    assert!(queue_is_empty(queue) == 0);
    queue_pop_tail(queue);
    assert!(queue_is_empty(queue) != 0);
    queue_free(queue);
}
static mut tests_test_queue: [UnitTestFunction; 9] = unsafe {
    [
        Some(test_queue_new_free as unsafe extern "C" fn() -> ()),
        Some(test_queue_push_head as unsafe extern "C" fn() -> ()),
        Some(test_queue_pop_head as unsafe extern "C" fn() -> ()),
        Some(test_queue_peek_head as unsafe extern "C" fn() -> ()),
        Some(test_queue_push_tail as unsafe extern "C" fn() -> ()),
        Some(test_queue_pop_tail as unsafe extern "C" fn() -> ()),
        Some(test_queue_peek_tail as unsafe extern "C" fn() -> ()),
        Some(test_queue_is_empty as unsafe extern "C" fn() -> ()),
        None,
    ]
};
unsafe fn main_0_test_queue(
    mut argc: libc::c_int,
    mut argv: *mut *mut libc::c_char,
) -> libc::c_int {
    run_tests(tests_test_queue.as_mut_ptr());
    return 0 as libc::c_int;
}
pub fn main_test_queue() {
    let mut args: Vec::<*mut libc::c_char> = Vec::new();
    for arg in ::std::env::args() {
        args.push(
            (::std::ffi::CString::new(arg))
                .expect("Failed to convert argument into CString.")
                .into_raw(),
        );
    }
    args.push(::core::ptr::null_mut());
    unsafe {
        ::std::process::exit(
            main_0_test_queue(
                (args.len() - 1) as libc::c_int,
                args.as_mut_ptr() as *mut *mut libc::c_char,
            ) as i32,
        )
    }
}
